import { pinyin } from "@/utils/pinyin";
const getStep2 = () => {
    const arr = [
        "项目名称",
        "投资年份",
        "投资金额",
        "总融资金额",
        "投咨期间",
        "过渡期增长率",
        "应收账款周转天数",
        "折现率",
        "总股东权益",
        "投后占股权比例",
        "过渡期年数",
        "永续增长率应",
        "付账款周转天数",
        "应付工资周转天数",
    ];
    return arr.map((str) => {
        const key = pinyin.getFullChars(str);

        return {
            key,
            keyName: str,
            value: "",
        };
    });
}
const getStep3 = () => {
    const arr = [
        "营业收入",
        "应付工资周转营业成本",
        "期间费用",
        "材料费占营业成本比",
        "人工占营业成本比",
        "期间费用率预估",
        "人工占期间费用比",
        "营业利润",
        "利润总额",
        "所得税",
        "净利润",
        "折旧摊销",
        "经营营运资本增加",
        "资本性支出",
        "股权自由现金流",
    ];
    return arr.map((str) => {
        return {
            name: str,
            year: "",
            value: "",
        };
    });
}
const getRandom = (size) => {
    return Array(size).fill(0).map(v => {
        const size = Math.floor(Math.random() * 100000000) / 100
        return size
    })
}
const getStep4 = (length = 0) => {
    const arr = [
        "营业收入增长率预估",
        "营业成本率预估",
        "期间费用率预估",
        "其他损益项目费率预估",
        "营业外收支",
        "所得税率预估",
        "折旧摊销增长率预估",
        "经营营运资本增加占收入增加%",
        "资本性支出/折旧摊销倍数",
        "现金流出",
    ];
    return arr.map((str) => {

        const list = length ? getRandom(length) : []
        return {
            name: str,
            value: list,
        };
    });
}
// 模拟接口返回，后续可删除
export const info = () => {
    return new Promise((resolve, reject) => {
        const formData = {
            step1: {
                operate: 1,
                rate: 1,
            },
            step2: {
                list: getStep2(),
            },
            step3: {
                list: getStep3(),
            },
            step4: {
                columnList: Array(5)
                    .fill(2022)
                    .map((v, index) => v + index),
                list: getStep4(),
            },
        };
        setTimeout(() => {
            resolve({
                data: formData,
            });
        }, 1000);
    });
}

const tab1 = [
    {
        name: '投资年份',
        value: '2022'
    },
    {
        name: '投资期间',
        value: '15'
    },
    {
        name: '折现率',
        value: '8.00%'
    }
]



const tab2 = [
    {
        name: '投资金额',
        value: 300000
    },
    {
        name: '总股东权益(投前)',
        value: 3500000
    },
    {
        name: '总融资金额',
        value: 600000
    },
    {
        name: '投后占股权比例',
        value: '8.00%'
    }
]




const tab3 = [
    {
        name: 'IRR',
        value: '21.37'
    },
    {
        name: 'NPV',
        value: 7891.86
    },
    {
        name: '静态回收期',
        value: '8.60'
    },
    {
        name: '动态回收期',
        value: '12.55'
    }
]


export const getInfoSuccessData = () => {
    return new Promise((resolve, reject) => {


        const data = {
            tab1, tab2, tab3,
            yuceData: {
                columnList: Array(5)
                    .fill(2022)
                    .map((v, index) => v + index),
                list: getStep4(5),
            },
        }
        setTimeout(() => {
            resolve({
                data
            });
        }, 1000);

    })

}